package com.mym.demo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

/**
 * @author miao
 * @version 1.0
 * @date 2025/4/15 9:14
 * @description
 */
public class Demo1 {
    public static void main(String[] args) {
        System.out.println(UUID.randomUUID());
        long time = System.currentTimeMillis();
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
        String format = df.format(time)+ UUID.randomUUID();
        System.out.println("format = " + format);



    }
    public static void main7(String[] args) {
        //获取系统环境变量
        System.out.println("System.getenv() = " + System.getenv());
        System.out.println("System.getenv(\"JAVA_HOME\") = " + System.getenv("JAVA_HOME"));

        //获取系统参数
        System.out.println("System.getProperties() = " + System.getProperties());
       // System.out.printf("System.getProperties(\"java.version\") = %s%n", System.getProperties("java.version")); //获取java版本号


    }
    public static void main6(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        System.out.println("now = " + now);
        //输出年份
        System.out.println("now.getYear() = " + now.getYear());
        System.out.println("now.getMonthValue() = " + now.getMonthValue());
        System.out.println("now.getDayOfMonth() = " +now.getDayOfMonth());
        System.out.println("now.getHour() = " + now.getHour());
        System.out.println("now.getMinute() = " + now.getMinute());
        System.out.println("now.getSecond() = " + now.getSecond());
        System.out.println("now.getNano() = " + now.getNano());
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        String format = now.format(dtf);
        System.out.println("format = " + format);
        String birthDate = "2024年06月11日";
        LocalDate parse = LocalDate.parse(birthDate, dtf);
        System.out.println("parse = " + parse);


    }

    public static void main5(String[] args)  {
        Calendar instance = Calendar.getInstance();
        int year = instance.get(Calendar.YEAR);
        int month = instance.get(Calendar.MONTH)+1;
        int day = instance.get(Calendar.DAY_OF_MONTH);
        System.out.println("year = " + year);
        System.out.println("month = " + month);
        System.out.println("day = " + day);
        instance.set(Calendar.YEAR,2025);
        instance.set(Calendar.MONTH,5);
        instance.set(Calendar.DAY_OF_MONTH,11);
        System.out.println("instance = " + instance.getTime());
        //将instance转换成日期
        Date time = instance.getTime();
        System.out.println("time = " + time);
        instance.set(2025,5,11);
        String format = new SimpleDateFormat("yyyy-MM-dd").format(time);
        System.out.println("format = " + format);

        System.out.println("instance = " + instance.getTime());

        System.out.println("instance = " + instance.getTime());
        instance.set(2026,4,6);
        System.out.println("instance = " + instance.getTime());
        instance.add(Calendar.YEAR,1);
        instance.add(Calendar.MONTH,1);
        instance.add(Calendar.DAY_OF_MONTH,1);
        System.out.println("instance = " + instance.getTime());
        instance.add(Calendar.YEAR,-1);
        instance.add(Calendar.MONTH,-1);
        instance.add(Calendar.DAY_OF_MONTH,-1)
                ;
        System.out.println("instance = " + instance.getTime());


    }
    public static void main3(String[] args) throws ParseException {
        String birthday = "2004-06-11";
        Date parse = new SimpleDateFormat("yyyy-mm-dd").parse(birthday);
        System.out.println("parse = " + parse.getTime());
        long time = parse.getTime();
        //系统的时间戳
        long time1 = System.currentTimeMillis();
        System.out.println("time1 - time = " + (time1 - time)/1000/60/60/24/365);

    }
    public static void main2(String[] args) {
        Date date = new Date();
        System.out.println("date = " + date);
        System.out.println("date.getTime() = " + date.getTime());
        date.setTime(1231313131313L);
        System.out.println("date = " + date);
    }
    public static void main1(String[] args) {
        StringBuffer sb = new StringBuffer();
        sb.append("hello");
        sb.append("world").append("java").append("dad").append("dada").append(new Object());
        System.out.println("sb = " + sb);
        sb.delete(0,5);
        System.out.println("sb = " + sb);
        sb.charAt(0);
        sb.setCharAt(0,'H');
        System.out.println(
                "sb = " + sb
        );
    }

    private static class random {
    }

    private static class randomuuid {
    }
}
